{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "s1 = pd.read_csv(\"../v1.0/Sub_v1.0.csv\")\n",
    "s2 = pd.read_csv(\"../v0.4/Sub_v0.4.csv\")\n",
    "s2 = s2.rename(columns={'Class_0':'0','Class_1':'1','Class_2':'2','Class_3':'3','Class_4':'4','Class_5':'5'})\n",
    "s3 = pd.read_csv(\"../v0.3/Sub_v0.3.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.173937</td>\n",
       "      <td>0.298217</td>\n",
       "      <td>0.204547</td>\n",
       "      <td>0.147925</td>\n",
       "      <td>0.072549</td>\n",
       "      <td>0.102825</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.110133</td>\n",
       "      <td>0.122854</td>\n",
       "      <td>0.260203</td>\n",
       "      <td>0.273058</td>\n",
       "      <td>0.031954</td>\n",
       "      <td>0.201797</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.299126</td>\n",
       "      <td>0.243916</td>\n",
       "      <td>0.170125</td>\n",
       "      <td>0.101204</td>\n",
       "      <td>0.126056</td>\n",
       "      <td>0.059572</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.379295</td>\n",
       "      <td>0.182181</td>\n",
       "      <td>0.237015</td>\n",
       "      <td>0.087934</td>\n",
       "      <td>0.061090</td>\n",
       "      <td>0.052487</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.170127</td>\n",
       "      <td>0.290687</td>\n",
       "      <td>0.136362</td>\n",
       "      <td>0.092038</td>\n",
       "      <td>0.180256</td>\n",
       "      <td>0.130530</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          0         1         2         3         4         5\n",
       "0  0.173937  0.298217  0.204547  0.147925  0.072549  0.102825\n",
       "1  0.110133  0.122854  0.260203  0.273058  0.031954  0.201797\n",
       "2  0.299126  0.243916  0.170125  0.101204  0.126056  0.059572\n",
       "3  0.379295  0.182181  0.237015  0.087934  0.061090  0.052487\n",
       "4  0.170127  0.290687  0.136362  0.092038  0.180256  0.130530"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "s1 = (s1 * 0.8 + s2 * 0.2) * 0.8 + s3 * 0.2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "train = pd.read_csv(\"../../Train.csv\")\n",
    "test = pd.read_csv(\"../../Test.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1, 3)\n",
      "(1, 3)\n",
      "(2, 3)\n",
      "(1, 3)\n"
     ]
    }
   ],
   "source": [
    "test_ids = []\n",
    "force_senti = []\n",
    "for index,row in test.iterrows():\n",
    "    temp = train[train['Text'] == row['Text']]\n",
    "    #temp = temp[temp['Text_Tag'] == row['Text_Tag']]\n",
    "    if temp.shape[0] > 0:\n",
    "        print(temp.shape)\n",
    "        force_senti.append(list(set(temp['Labels'].tolist()))[0])\n",
    "        test_ids.append(index)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "dic = {0:[1,0,0,0,0,0],1:[0,1,0,0,0,0],2:[0,0,1,0,0,0],3:[0,0,0,1,0,0],4:[0,0,0,0,1,0],5:[0,0,0,0,0,1]}\n",
    "for x,y in zip(test_ids,force_senti):\n",
    "    #print(samp.iloc[x])\n",
    "    target = dic[y]\n",
    "    s1.iloc[x] = target\n",
    "    #print(samp.iloc[x])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.191108</td>\n",
       "      <td>0.248477</td>\n",
       "      <td>0.196124</td>\n",
       "      <td>0.156171</td>\n",
       "      <td>0.097901</td>\n",
       "      <td>0.110219</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.113736</td>\n",
       "      <td>0.159836</td>\n",
       "      <td>0.235672</td>\n",
       "      <td>0.252732</td>\n",
       "      <td>0.038258</td>\n",
       "      <td>0.199766</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.257664</td>\n",
       "      <td>0.229760</td>\n",
       "      <td>0.165637</td>\n",
       "      <td>0.128482</td>\n",
       "      <td>0.104970</td>\n",
       "      <td>0.113487</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.317320</td>\n",
       "      <td>0.206074</td>\n",
       "      <td>0.232265</td>\n",
       "      <td>0.090564</td>\n",
       "      <td>0.082512</td>\n",
       "      <td>0.071265</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.170472</td>\n",
       "      <td>0.292705</td>\n",
       "      <td>0.148634</td>\n",
       "      <td>0.100051</td>\n",
       "      <td>0.152672</td>\n",
       "      <td>0.135465</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          0         1         2         3         4         5\n",
       "0  0.191108  0.248477  0.196124  0.156171  0.097901  0.110219\n",
       "1  0.113736  0.159836  0.235672  0.252732  0.038258  0.199766\n",
       "2  0.257664  0.229760  0.165637  0.128482  0.104970  0.113487\n",
       "3  0.317320  0.206074  0.232265  0.090564  0.082512  0.071265\n",
       "4  0.170472  0.292705  0.148634  0.100051  0.152672  0.135465"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "s1.to_csv('Sub_v1.5.csv', index=False)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
